package com.xr.redis.pubsub.service;

import com.xr.redis.pubsub.model.Message;
import com.xr.redis.pubsub.service.listener.AbstractPubSubListener;

/**
 * @author Arnold Yand
 * @summary 发布/订阅 服务
 * @time 2018/8/4 13:50
 */
public interface IPubSubService {

  /**
   * 发布消息
   * @param channel
   * @param message
   * @throws Exception
   */
  void publish(String channel, Message message) throws Exception;

  /**
   * 订阅频道
   * @param channel
   * @param listener
   * @throws Exception
   */
  void subscribe(String channel, AbstractPubSubListener listener) throws Exception;

  /**
   * 取消订阅频道
   * @param channel
   * @param listener
   * @throws Exception
   */
  void unSubscribe(String channel, AbstractPubSubListener listener) throws Exception;
}
